package com.example.mytips.utils;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.psi.PsiFile;

public class SelectFileInfo {

    ///获取当前选中的文件名,不带后缀
    public static String getFileName(AnActionEvent e) {
        DataContext context = e.getDataContext();

        PsiFile psiFile = CommonDataKeys.PSI_FILE.getData(context);
        if (psiFile == null) {
            return "";
        }
        String path = psiFile.getVirtualFile().getPath();
        return PathUtil.getFileName(path);
    }
}
